package flc.ast.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class CarWorksAdapter extends StkProviderMultiAdapter<String> {

    public CarWorksAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(150));
        addItemProvider(new CarWorksProvider());
    }


    private class CarWorksProvider extends BaseItemProvider<String> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_car_works;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, String bean) {
            Glide.with(getContext()).load(bean)
                    .into((ImageView) baseViewHolder.getView(R.id.ivCarWorksItemImg));
            if (baseViewHolder.getBindingAdapterPosition()==0||baseViewHolder.getBindingAdapterPosition()%3==0){
                baseViewHolder.getView(R.id.rlCarWorksItemBg).setBackgroundResource(R.drawable.zpk1);
            }else if (baseViewHolder.getBindingAdapterPosition()%3==1){
                baseViewHolder.getView(R.id.rlCarWorksItemBg).setBackgroundResource(R.drawable.zpk2);
            }else if (baseViewHolder.getBindingAdapterPosition()%3==2){
                baseViewHolder.getView(R.id.rlCarWorksItemBg).setBackgroundResource(R.drawable.zpk3);
            }
        }
    }
}
